package com.nirvana.admin.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.nirvana.admin.entity.SysRole;
import com.nirvana.admin.mapper.SysRoleMapper;
import com.nirvana.admin.service.SysRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collection;

/**
 * <p>
 * 角色信息表 服务实现类
 * </p>
 *
 * @author zhangshuaiyin
 * @since 2021-09-29
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

    @Override
    public boolean hasAnyAdmin(Collection<SysRole> roleList) {
        if (CollectionUtil.isEmpty(roleList)) {
            return Boolean.FALSE;
        }
        return roleList.stream().anyMatch(roleDO -> "admin".equals(roleDO.getCode()));
    }
}
